<?php

class Model_IssuesOptions implements FormOptionsInterface
{
	private $community_oid;
	private $store;

	public function __construct(ObjectStore $store) {
		$this->store = $store;
	}

	public function init($community_oid) {
		$this->community_oid = $community_oid;
	}

	public function getData() {
		$sql = "SELECT iss.oid, iss.issue_number, iss.issue_name, section.title FROM store_class_issue iss
		LEFT JOIN store_class_tdi section ON (section.oid = iss.tdi_oid and section.community_oid = iss.community_oid)
		WHERE iss.community_oid = ".$this->community_oid;
		$rs = $this->store->findSQL($sql);

		// поиск итема
		$result = array();
		while ($item = $rs->next()) {
			$data = $rs->rs->current();
			if ( $data['is_deleted']==0 ) {
				$result[ $data['oid'] ] = $data[ "issue_number" ].": ".$data[ "issue_name" ].($data['title'] ? " (".$data[ "title" ].")" : '');
			}
		}
		$result[''] = "не выбран";

		return $result;
	}


}
